package com.arellomobile.android.push;

import android.content.Context;
import android.location.Location;
import android.util.Log;
import com.arellomobile.android.push.data.PushZoneLocation;
import com.arellomobile.android.push.request.RequestHelper;
import com.arellomobile.android.push.utils.NetworkUtils;
import com.arellomobile.android.push.utils.NetworkUtils.NetworkResult;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONObject;

public class DeviceFeature2_5
{
  private static final String APP_OPEN = "applicationOpen";
  private static final String GOAL_ACHIEVED = "applicationEvent";
  private static final String MSG_DELIVERED = "messageDeliveryEvent";
  private static final String NEAREST_ZONE = "getNearestZone";
  private static final String PACKAGE_REMOVED = "androidPackageRemoved";
  private static final String PUSH_STAT = "pushStat";
  private static final String TAG = "PushWoosh DeviceFeature2_5";
  private static final String TAGS_PATH = "setTags";

  public static PushZoneLocation getNearestZone(Context paramContext, Location paramLocation)
    throws Exception
  {
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getNearestZoneData(paramContext, paramLocation, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To Sent Nearest Zone");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: sent Nearest Zone " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult, (Throwable)localObject);
        throw ((Throwable)localObject);
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "getNearestZone");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send Nearest Zone success");
            PushZoneLocation localPushZoneLocation = RequestHelper.getPushZoneLocationFromData(localNetworkResult.getResultData(), "1.3");
            return localPushZoneLocation;
          }
        }
        catch (Exception localException)
        {
          localObject = localException;
          i++;
        }
      }
    }
  }

  public static void sendAppOpen(Context paramContext)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getSendAppOpenData(paramContext, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To sent AppOpen");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: Try To sent AppOpen " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult.getResultData(), (Throwable)localObject);
        return;
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "applicationOpen");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send AppOpen success");
          }
        }
        catch (Exception localException)
        {
          localObject = localException;
          i++;
        }
      }
    }
  }

  static void sendAppRemovedData(Context paramContext, String paramString)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getAppRemovedData(paramContext, paramString, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To sent AppRemoved");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: Try To sent AppRemoved " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult.getResultData(), (Throwable)localObject);
        return;
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "androidPackageRemoved");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send AppRemoved success");
          }
        }
        catch (Exception localException)
        {
          localObject = localException;
          i++;
        }
      }
    }
  }

  public static void sendGoalAchieved(Context paramContext, String paramString, Integer paramInteger)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getSendGoalAchievedData(paramContext, paramString, paramInteger, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To sent Goal");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: Try To sent PushStat " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult.getResultData(), (Throwable)localObject);
        return;
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "applicationEvent");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send Goal success");
          }
        }
        catch (Exception localException)
        {
          localObject = localException;
          i++;
        }
      }
    }
  }

  public static void sendMessageDeliveryEvent(Context paramContext, String paramString)
  {
    if (paramString == null)
      return;
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getSendPushStatData(paramContext, paramString, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To sent MsgDelivered");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: Try To sent MsgDelivered " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult.getResultData(), (Throwable)localObject);
        return;
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "messageDeliveryEvent");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send MsgDelivered success");
          }
        }
        catch (Exception localException)
        {
          localObject = localException;
          i++;
        }
      }
    }
  }

  public static void sendPushStat(Context paramContext, String paramString)
  {
    if (paramString == null)
      return;
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getSendPushStatData(paramContext, paramString, "1.3"));
    Log.w("PushWoosh DeviceFeature2_5", "Try To sent PushStat");
    NetworkUtils.NetworkResult localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
    Object localObject = new Exception();
    int i = 0;
    while (true)
    {
      if (i >= 5)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: Try To sent PushStat " + ((Exception)localObject).getMessage() + ". Response = " + localNetworkResult.getResultData(), (Throwable)localObject);
        return;
      }
      try
      {
        localNetworkResult = NetworkUtils.makeRequest(localHashMap, "pushStat");
        if (200 == localNetworkResult.getResultCode())
        {
          Log.w("PushWoosh DeviceFeature2_5", "Send PushStat success");
          return;
        }
      }
      catch (Exception localException)
      {
        localObject = localException;
        i++;
      }
    }
  }

  public static JSONArray sendTags(Context paramContext, Map<String, Object> paramMap)
    throws Exception
  {
    HashMap localHashMap = new HashMap();
    localHashMap.putAll(RequestHelper.getSendTagsData(paramContext, "1.3"));
    JSONObject localJSONObject1 = new JSONObject();
    Iterator localIterator1 = paramMap.keySet().iterator();
    NetworkUtils.NetworkResult localNetworkResult;
    Object localObject3;
    int i;
    if (!localIterator1.hasNext())
    {
      localHashMap.put("tags", localJSONObject1);
      Log.w("PushWoosh DeviceFeature2_5", "Try To sent Tags");
      localNetworkResult = new NetworkUtils.NetworkResult(500, 0, null);
      localObject3 = new Exception();
      i = 0;
    }
    while (true)
    {
      if (i >= 5);
      while (true)
      {
        Log.e("PushWoosh DeviceFeature2_5", "ERROR: sent Tags " + ((Exception)localObject3).getMessage() + ". Response = " + localNetworkResult, (Throwable)localObject3);
        throw ((Throwable)localObject3);
        String str = (String)localIterator1.next();
        Object localObject1 = paramMap.get(str);
        if (((localObject1 instanceof String)) || ((localObject1 instanceof Integer)))
        {
          localJSONObject1.put(str, localObject1);
          break;
        }
        if ((localObject1 instanceof List))
        {
          JSONArray localJSONArray1 = new JSONArray();
          Iterator localIterator2 = ((List)localObject1).iterator();
          while (true)
          {
            if (!localIterator2.hasNext())
            {
              localJSONObject1.put(str, localJSONArray1);
              break;
            }
            Object localObject2 = localIterator2.next();
            if ((!(localObject2 instanceof String)) && (!(localObject2 instanceof Integer)))
              break label282;
            localJSONArray1.put(String.valueOf(localObject2));
          }
          label282: throw new RuntimeException("wrong type for tag: " + str);
        }
        if ((localObject1 instanceof JSONArray))
        {
          localJSONObject1.put(str, (JSONArray)localObject1);
          break;
        }
        throw new RuntimeException("wrong type for tag: " + str);
        try
        {
          localNetworkResult = NetworkUtils.makeRequest(localHashMap, "setTags");
          if (200 == localNetworkResult.getResultCode())
          {
            if (200 != localNetworkResult.getPushwooshCode())
              continue;
            Log.w("PushWoosh DeviceFeature2_5", "Send Tags success");
            JSONObject localJSONObject2 = localNetworkResult.getResultData().getJSONObject("response");
            if (localJSONObject2 == null)
              return new JSONArray();
            JSONArray localJSONArray2 = localJSONObject2.getJSONArray("skipped");
            return localJSONArray2;
          }
        }
        catch (Exception localException)
        {
          localObject3 = localException;
          i++;
        }
      }
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.arellomobile.android.push.DeviceFeature2_5
 * JD-Core Version:    0.6.2
 */